import request from "../utils/request";
import type { User, UserListResponse, UserUpdateRequest } from "../types/user";

/**
 * 获取用户列表
 * @param params 查询参数
 */
export const getUserList = (params?: {
  skip?: number;
  limit?: number;
  username?: string;
  email?: string;
}): Promise<UserListResponse> => {
  return request.get("/admin/users", { params });
};

/**
 * 获取用户详情
 * @param userId 用户ID
 */
export const getUserDetail = (userId: number): Promise<User> => {
  return request.get(`/admin/users/${userId}`);
};

/**
 * 更新用户信息
 * @param userId 用户ID
 * @param data 更新数据
 */
export const updateUser = (
  userId: number,
  data: UserUpdateRequest
): Promise<User> => {
  return request.put(`/admin/users/${userId}`, data);
};

/**
 * 删除用户
 * @param userId 用户ID
 */
export const deleteUser = (
  userId: number
): Promise<{ message: string; username: string }> => {
  return request.delete(`/admin/users/${userId}`);
};
